// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Core.RankEval;

/// <summary>
/// <para>Expected Reciprocal Rank (ERR)</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/search-rank-eval.html#_expected_reciprocal_rank_err">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public sealed partial class RankEvalMetricExpectedReciprocalRank
{
	/// <summary>
	/// <para>Sets the maximum number of documents retrieved per query. This value will act in place of the usual size parameter in the query.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("k")]
	public int? k { get; set; }

	/// <summary>
	/// <para>The highest relevance grade used in the user-supplied relevance judgments.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("maximum_relevance")]
	public int MaximumRelevance { get; set; }
}

/// <summary>
/// <para>Expected Reciprocal Rank (ERR)</para>
/// <para><see href="https://www.elastic.co/guide/en/elasticsearch/reference/8.13/search-rank-eval.html#_expected_reciprocal_rank_err">Learn more about this API in the Elasticsearch documentation.</see></para>
/// </summary>
public sealed partial class RankEvalMetricExpectedReciprocalRankDescriptor : SerializableDescriptor<RankEvalMetricExpectedReciprocalRankDescriptor>
{
	internal RankEvalMetricExpectedReciprocalRankDescriptor(Action<RankEvalMetricExpectedReciprocalRankDescriptor> configure) => configure.Invoke(this);

	public RankEvalMetricExpectedReciprocalRankDescriptor() : base()
	{
	}

	private int? kValue { get; set; }
	private int MaximumRelevanceValue { get; set; }

	/// <summary>
	/// <para>Sets the maximum number of documents retrieved per query. This value will act in place of the usual size parameter in the query.</para>
	/// </summary>
	public RankEvalMetricExpectedReciprocalRankDescriptor k(int? k)
	{
		kValue = k;
		return Self;
	}

	/// <summary>
	/// <para>The highest relevance grade used in the user-supplied relevance judgments.</para>
	/// </summary>
	public RankEvalMetricExpectedReciprocalRankDescriptor MaximumRelevance(int maximumRelevance)
	{
		MaximumRelevanceValue = maximumRelevance;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (kValue.HasValue)
		{
			writer.WritePropertyName("k");
			writer.WriteNumberValue(kValue.Value);
		}

		writer.WritePropertyName("maximum_relevance");
		writer.WriteNumberValue(MaximumRelevanceValue);
		writer.WriteEndObject();
	}
}